home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 26
/
Cream of the Crop 26.iso
/
program
/
qlib205.zip
/
QLIB.ZIP
/
TEST
/
PACK
/
PACK.ASM
< prev
next >
Wrap
Assembly Source File
|
1997-02-12
|
2KB
|
100 lines
;this example uses pack_open()
include qlib.inc
include dos.inc
include string.inc
include stdio.inc
include process.inc
include data_hdr.asm
.data
buf db 1024 dup (0)
buf2 db 1024 dup (0)
h dw ?
siz dd ?
ph dw ? ;pack file handle
.code
main proc
callp pack_init,256,2
.if eax==ERROR
callp printf,"\npack_init() failed!\n"
callp exit,0
.endif
callp pack_open,"data.000"
.if eax==ERROR
callp printf,"\npack_open() failed!\n"
callp exit,0
.endif
mov ph,ax
callp open,"file1",0
mov h,ax
.if eax==ERROR
callp printf,"\nopen(file1) failed!\n"
callp exit,0
.endif
callp lseek,h,0,SEEK_SET
callp lseek,h,1,SEEK_CUR ;test lseeking with a pack file (skip the 1st byte)
callp filelength,h
mov siz,eax
callp read,h,offset buf,132 ;filesiz=132 but we have lseek one byte over
;what will happen? pack.asm will cut it off so we
;don't start reading the next file.
.if eax!=131
callp printf,"error read eax=%d\n",eax
.endif
callp read,h,offset buf,100 ;try to read more : it will fail
.if eax
callp printf,"Error #2\n"
.endif
callp printf,offset buf
callp eof,h
.if eax
callp printf,"\nEOF=true\n"
.else
callp printf,"\nEOF=false (bug?)\n"
.endif
callp printf,"\n File length of FILE1=%d\n\n",siz
callp close,h
callp pack_close,ph ;you can open many pack's if you want
.if eax==ERROR
callp printf,"\n pack_close() failed!\n"
callp exit,0
.endif
callp pack_open_hdr,"data.001",offset the_header
.if eax==ERROR
callp printf,"\n pack_open_hdr() failed!\n"
callp exit,0
.endif
mov ph,ax
callp open,"file2",0 ;this will fail if pack_close() above is unremed
mov h,ax
.if ax==ERROR
callp printf,"\nopen(file2) failed!\n"
callp exit,0
.endif
callp read,h,offset buf2,300
callp close,h
callp printf,offset buf2
;some xtra lseek tests
callp lseek,h,0,SEEK_END
callp printf," Pos 1=%i",eax
callp lseek,h,303,SEEK_END
callp printf," Pos 2=%i",eax
callp lseek,h,304,SEEK_END
callp printf," Pos 3=%i",eax
callp lseek,h,-303,SEEK_CUR
callp printf," Pos 4=%i",eax
callp lseek,h,303,SEEK_SET
callp printf," Pos 5=%i",eax
callp lseek,h,-309,SEEK_CUR
callp printf," Pos 6=%i",eax
callp lseek,h,1,SEEK_END
callp printf," Pos 7=%i",eax
ret
main endp
end